<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<!DOCTYPE html>
<html lang="en">
<head>
    <%
        String path = request.getContextPath();
        String basePath = request.getScheme() + "://"
                + request.getServerName() + ":" + request.getServerPort()
                + path;
    %>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>图片分享后台</title>
    <!-- 基本配置文件会先放在前面 -->
    <link rel="stylesheet" type="text/css" href="../resources/package/bootstrap/css/bootstrap.css">
    <link rel="stylesheet" type="text/css" href="../resources/package/font-awesome-4.7.0/css/font-awesome.min.css">
    <link rel="stylesheet" type="text/css" href="../resources/manager/css/base.css">
    <link rel="stylesheet" type="text/css" href="../resources/manager/css/keyword.css">
    <link rel="stylesheet" type="text/css" href="../resources/manager/css/form.css">
    <link rel="stylesheet" type="text/css" href="../resources/manager/css/nav.css">
    <script type="text/javascript" src="../resources/package/jquery/jquery-3.1.1.min.js"></script>
    <script type="text/javascript" src="../resources/package/layer/layer.js"></script>
    <script>
        $(function () {
            var count = 0;
            $(".myshow").click(function () {
                console.log("1");
                count = (count+1)%2;
                if(count==1){
                    $(".user-nav").css("display","block")
                }else{
                    $(".user-nav").css("display","none")
                }
            });
//            console.log( $(".deleteKeywordBtn"))
            $(".dealIsShareBtn").click(function () {
//                event.returnValue = confirm("删除是不可恢复的，你确认要删除吗？");
                let that=$(this);
                layer.confirm('是否改变分享状态？', {
                    title: "分享状态操作",
                    btn: ['确认', '取消'] //按钮
                }, function (index) {
                    console.log(that.find("button").attr("value"));
                    layer.close(index);
                    $.ajax({
                        type: "POST",
                        url: "<%=basePath%>/admin/manageUser",
                        data: {
                            id:that.find("button").attr("value"),
                            pn:${pn}
                        },
                        xhrFields: {
                            withCredentials: true
                        },
                        crossDomain: true,
                        dataType: "json",
                        success: function (data) {
                            console.log(data.isShare);
                            if(data.isShare==1){
                                that.parent("td").prev().html("允许");
                                that.find("button").removeClass("btn-primary").addClass("btn-danger");
                                that.find("button").children().replaceWith("<span class='glyphicon glyphicon-remove'>禁止分享</span>");
                            }else{
                                that.parent("td").prev().html("禁止");
                                that.find("button").removeClass("btn-danger").addClass("btn-primary");
                                that.find("button").children().replaceWith("<span class='glyphicon glyphicon-ok'>允许分享</span>");
                            }
                            layer.msg('操作成功！', {
                                time: 500
                            });
                        },
                        error: function (data) {
                            console.log(data)
                            layer.msg('操作失败！', {
                                time: 500
                            });
                        }
                    });
                }, function (index) {
                    layer.msg('取消了操作', {
                        time: 500
                    });
                });
            });
        });

    </script>
</head>
<body>
<div class="header-wrapper">
    <div class="header">
        <div class="nav-left">
            <i class="glyphicon glyphicon-align-justify"></i>
        </div>
        <div class="nav-middle">
            <div class="logoInfo">
                <a class="logo">图片分享后台</a>
            </div>
        </div>
        <div class="nav-right">
            <!--fontawesome字体图标-->
            <a class="myshow"><i class="glyphicon glyphicon-user"></i></a>
        </div>
        <!--<a>账户</a>-->
        <div class="user-nav" >
            <div class="triangle"></div>
            <div class="triangle-shadow"></div>
            <div class="user-nav-wrapper" style="background-color: #010001;">
                <div class="user-info">
                    <div class="user-img">
                        <i class="glyphicon glyphicon-user" style="color: white"></i>
                    </div>
                    <div class="" style="color: #ffffff">${currentAdmin.account}</div>
                </div>
                <div class="user-item">
                    <a class="" style="color: #ffffff">个人资料</a>
                </div>
                <div class="user-item">
                    <a  href="<%=basePath%>/user/updatepassword?isAdmin=true" style="color: #ffffff">修改密码</a>
                </div>
                <div class="user-item">
                    <a href="<%=basePath%>/admin/addAdmin" style="color: #ffffff">添加管理员</a>
                </div>
                <div class="user-item">
                    <a  href="<%=basePath%>/admin/logout" style="color: #ffffff">退出</a>
                </div>
            </div>
        </div>
    </div>
</div>
<div class="content-wrapper">
    <div class="left-model">
        <div class="left-model-header">
            <a class="model-title-left">图片分享</a>
            <a class="model-title-right"><i class="fa fa-angle-right"></i></a>
        </div>
        <div class="left-model-middle">
            <a class="left-model-item">
                <i class="icon glyphicon glyphicon-home"></i>
                <span class="content">首页</span>
            </a>
        </div>
        <div class="left-model-bottom">
            <div class="info">图片分享程序</div>
            <div class="info"><a>隐私政策 </a><a> 服务条款</a></div>
            <div class="info"><a>©2017 易拓工作室</a></div>
        </div>
    </div>
    <div class="left">
        <ul class="left-header">
            <li class="left-item">
                <a class="content left-item-height" href="<%=basePath%>/admin/adminIndex"> <i class="icon glyphicon glyphicon-home"></i>首页</a>
            </li>
            <li class="left-item">
                <a class="content left-item-height"> <i class="icon glyphicon glyphicon-user"></i>用户管理<i class="icon-right glyphicon glyphicon-chevron-down"></i></a>
                <ul class="twoRank">
                    <li>
                        <a class="left-item-height twoRank-a" href="<%=basePath%>/admin/manageUser?pn=1">
                            <i class="icon glyphicon glyphicon-chevron-right"></i>
                            用户操作
                        </a>
                    </li>
                    <li class="twoRank-li">
                        <a class="left-item-height twoRank-a" href="<%=basePath%>/admin/addAdmin">
                            <i class="icon glyphicon glyphicon-chevron-right"></i>
                            添加管理员
                        </a>
                    </li>
                </ul>
            </li>
            <li class="left-item">
                <a class="content left-item-height"> <i class="icon glyphicon glyphicon-bold"></i>关键字管理<i class="icon-right glyphicon glyphicon-chevron-down"></i></a>
                <ul class="twoRank">
                    <li>
                        <a class="left-item-height twoRank-a" href="<%=basePath%>/admin/keyword?pn=1">
                            <i class="icon glyphicon glyphicon-chevron-right"></i>
                            关键字操作
                        </a>
                    </li>
                </ul>
            </li>
            <li class="left-item">
                <a class="content left-item-height"> <i class="icon glyphicon glyphicon-share-alt"></i>举报审核<i class="icon-right glyphicon glyphicon-chevron-down"></i></a>
                <ul class="twoRank">
                    <li>
                        <a class="left-item-height twoRank-a" href="<%=basePath%>/admin/examineList?pn=1&select=0">
                            <i class="icon glyphicon glyphicon-chevron-right"></i>
                            审核列表
                        </a>
                    </li>
                    <li class="twoRank-li">
                        <a class="left-item-height twoRank-a" href="<%=basePath%>/admin/examineList?pn=1&select=-1">
                            <i class="icon glyphicon glyphicon-chevron-right"></i>
                            待审核列表
                        </a>
                    </li>
                    <li class="twoRank-li">
                        <a class="left-item-height twoRank-a" href="<%=basePath%>/admin/examineList?pn=1&select=1">
                            <i class="icon glyphicon glyphicon-chevron-right"></i>
                            已审核列表
                        </a>
                    </li>
                </ul>
            </li>
            <li class="left-item">
                <a class="content left-item-height"> <i class="icon glyphicon glyphicon-list"></i>系统公告<i class="icon-right glyphicon glyphicon-chevron-down"></i></a>
                <ul class="twoRank">
                    <li>
                        <a class="left-item-height twoRank-a" href="<%=basePath%>/admin/info?pn=1">
                            <i class="icon glyphicon glyphicon-chevron-right"></i>
                            公告管理
                        </a>
                    </li>
                </ul>
            </li>
            <li class="left-item setting">
                <a class="content left-item-height"><i class="icon glyphicon glyphicon-certificate"></i>设置</a>
            </li>
        </ul>
    </div>
    <div class="right">
        <div class="right-inner">
            <div class=col-md-12" id="middle-right-content">
                <div class="middle-right-header">
                    <a href="<%=basePath%>/admin/adminIndex"><span>首页  / </span></a>
                    <a href="<%=basePath%>/admin/manageUser?pn=1"><span>用户操作</span></a>
                </div>
                <div class="search form-group">
                    <%--<span class="deleteMoreUser">批量删除<i class="glyphicon glyphicon-minus"></i></span>--%>
                    <%--<span class="addUser">添加成员<i class="glyphicon glyphicon-plus"></i></span>--%>
                    <%--<input class="form-control" placeholder="请输入搜索内容"><i class="glyphicon glyphicon-search" title="搜索"></i>--%>
                    <form class="InputForm" action="<%=basePath%>/admin/searchUser?pn=1" method="post">
                        <input class="searchInput form-control" placeholder="请输入搜索内容" name="searchUserValue" value=${searchUserValue}>
                        <i class="clearCont glyphicon glyphicon-remove-circle" title="清空"></i>
                        <button class="btn btn-search searchKeywordBtn">
                            <i class="glyphicon glyphicon-search " title="搜索"></i>
                        </button>
                    </form>
                </div>
                <table class="table table-striped table-bordered table-hover">
                    <tbody class="tbody" id="Tbody">
                    <tr>
                        <td><STRONG>编号</STRONG></td>
                        <td><STRONG>用户账号</STRONG></td>
                        <td><STRONG>用户名</STRONG></td>
                        <td><STRONG>性别</STRONG></td>
                        <td><STRONG>注册时间</STRONG></td>
                        <td><STRONG>分享状态</STRONG></td>
                        <td><STRONG>操作</STRONG></td>
                    </tr>
                    <c:set var="pages" value="${pages}"/>
                    <c:set var="pn" value="${pn}"/>
                    <c:set var="pnT" value="${pn}"/>
                    <c:set var="count" value="${(pn-1)*10}"/>
                    <c:choose>
                        <c:when test="${pn%3==0}">
                            <c:set var="pn" value="${pn-2-pn%3}"/>
                        </c:when>
                        <c:otherwise>
                            <c:set var="pn" value="${1+pn-pn%3}"/>
                        </c:otherwise>
                    </c:choose>
                    <c:forEach var="u" items="${userList}">
                        <c:set var="count" value="${count+1}"/>
                        <tr>
                            <td>${count}</td>
                            <td>${u.account}</td>
                            <td>${u.username}</td>
                            <td>
                                <c:if test="${u.sex==0}">女</c:if>
                                <c:if test="${u.sex!=0}">男</c:if>
                            </td>
                            <td><fmt:formatDate value="${u.createTime}" pattern="yyyy-MM-dd hh:mm:ss" type="date" dateStyle="long"/></td>
                            <td>
                                <c:choose>
                                    <c:when test="${u.isShare==0}">禁止</c:when>
                                    <c:otherwise>允许</c:otherwise>
                                </c:choose>
                            </td>
                            <td>
                                <c:choose>
                                    <c:when test="${u.isShare==0}">
                                        <a  class="dealIsShareBtn">
                                            <button class="btn btn-primary " type="button" value="${u.id}">
                                                <span class="glyphicon glyphicon-ok">允许分享</span>
                                            </button>
                                        </a>
                                    </c:when>
                                    <c:otherwise>
                                        <a  class="dealIsShareBtn">
                                            <button class="btn btn-danger" type="button" value="${u.id}">
                                                <span class="glyphicon glyphicon-remove">禁止分享</span>
                                            </button>
                                        </a>
                                    </c:otherwise>
                                </c:choose>
                            </td>
                        </tr>
                    </c:forEach>
                    </tbody>
                </table>
                <div class="bottom">
                    <footer>
                        <ul class="pagination">
                            <li><a href="<%=basePath%>/admin/searchUser?pn=1&searchUserValue=${searchUserValue}">首页</a></li>
                            <li><a href="<%=basePath%>/admin/searchUser?pn=${pn-1==0?1:pn-1}&searchUserValue=${searchUserValue}"><<</a></li>
                            <li><a href="<%=basePath%>/admin/searchUser?pn=${pn}&searchUserValue=${searchUserValue}">${pn}</a></li>
                            <li><a href="<%=basePath%>/admin/searchUser?pn=${pn+1>pages?pn:pn+1}&searchUserValue=${searchUserValue}">${pn+1}</a></li>
                            <li><a href="<%=basePath%>/admin/searchUser?pn=${pn+2>pages?(pn+1>pages?pn:pn+1):pn+2}&searchUserValue=${searchUserValue}">${pn+2}</a></li>
                            <li><a href="<%=basePath%>/admin/searchUser?pn=${pn+3>pages?pn:pn+3}&searchUserValue=${searchUserValue}">>></a></li>
                            <li><a href="<%=basePath%>/admin/searchUser?pn=${pages}&searchUserValue=${searchUserValue}">末页</a></li>
                            <li><a>总页数：${pages}</a></li>
                        </ul>
                    </footer>
                </div>
            </div>
        </div>
    </div>
</div>
</body>
<script type="text/javascript" src="../resources/manager/js/app/base.js"></script>
<script type="text/javascript" src="../resources/manager/js/app/keyword.js"></script>
<script type="text/javascript" src="../resources/manager/js/app/tool.js"></script>
<script type="text/javascript" src="../resources/manager/js/app/fade.js"></script>
<script type="text/javascript" src="../resources/manager/js/app/shareFunction.js"></script>
</html>